'''
Created on 2021年5月6日

@author: shuyu5433
'''
import unittest
from utilities.CommonConfig import CommonConfig
from login.loginTest import loginTest
import time
import unittest
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.common.by import By


class testHome(unittest.TestCase):

    @classmethod
    def setUpClass(cls):
        testHome.driver = loginTest.login('')

    def test_home(self):

        urls = self.driver.find_elements_by_xpath("//a")

        for url in urls:
            print(url.get_attribute("href"))
            if(url.get_attribute("href") == "http://222.76.113.125:38080/dashboard/analysis"):
                url.click()
                break

    def test_home_notice(self):
        print("aaaaa")
        time.sleep(20)
        #self.driver = loginTest.login('')
        link = self.driver.find_element_by_link_text("更多")
        link.click()

    def test_home_search(self):
        #self.driver = loginTest.login('')

        urls = self.driver.find_elements_by_xpath("//a")

        for url in urls:
            print(url.get_attribute("href"))
            if(url.get_attribute("href") == "http://222.76.113.125:38080/dashboard/analysis"):
                url.click()
                print("bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb")
                break
        print("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
        element = self.driver.find_element(By.CSS_SELECTOR, ".leftTop")
        actions = ActionChains(self.driver)
        actions.move_to_element(element).perform()
        self.driver.find_element(By.CSS_SELECTOR, ".leftTop").click()
        self.driver.find_element(By.CSS_SELECTOR, ".ant-input").click()

        self.driver.find_element(
            By.CSS_SELECTOR, ".ant-input").send_keys("道庆洲")
        self.driver.find_element(
            By.CSS_SELECTOR, ".ant-btn:nth-child(1)").click()
        self.driver.find_element(By.LINK_TEXT, "查看").click()


if __name__ == "__main__":
    #import sys;sys.argv = ['', 'testHome.test_home']
    unittest.main()
